package com.zfast.yugioh.junit;

import com.zfast.yugioh.junit.observer.ObservableDemo;
import com.zfast.yugioh.junit.observer.ObservedObject;
import org.junit.jupiter.api.Test;

import java.util.Observable;
import java.util.Observer;

//去除name对象
public class 监测者Junit{//只能监听对象值的变化\
    @Test
    public void egMax() {//e.g.
        //region 1.模拟数据
        System.out.println("--------------------Start--------------------");
        //endregion

        //region 2.数据处理
        System.out.println("--------------------Deal--------------------");
        //endregion

        //region 3.数据展示
        System.out.println("--------------------Done--------------------");
        //endregion
    }
    @Test
    public void 调用监测者_egMin() {//e.g.
        // create watched and watcher objects
        ObservedObject watched = new ObservedObject("Original Value");
        // watcher object listens to object change
        ObservableDemo watcher = new ObservableDemo();
        // add observer to the watched object
        watched.addObserver(watcher);

        // trigger value change
        //System.out.println("setValue method called...");
        watched.setValue("New Value");
        // check if value has changed
        if(watched.hasChanged())
            System.out.println("Value changed");
        else
            System.out.println("Value not changed");
    }

    @Test
    public void 无Observer_egMin() {//e.g.
        // create watched and watcher objects
        ObservedObject watched = new ObservedObject("Original Value");

        // trigger value change
        watched.setValue("New Value");

        System.out.println(watched.hasChanged());

    }

    @Test
    public void egMin() {//e.g.
        System.out.println();
    }
}
